<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增总章节')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-chapter-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">父章节名称：</label>
                <div class="col-sm-8">
                    <input id="treeId" name="fatherId" type="hidden" th:value="${featherChapter?.chapterId}"/>
                    <input name="courseId" class="form-control" type="hidden" th:value="${courseId}">
                    <input class="form-control" type="text" id="treeName" readonly="true" th:value="${featherChapter?.chapterName}" th:readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">章节名称：</label>
                <div class="col-sm-8">
                    <input name="chapterName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">章节序列：</label>
                <div class="col-sm-8">
                    <input name="chapterSort" class="form-control" type="text" placeholder="递增排序">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">章节视频：</label>
                <div class="col-sm-8">
                    <input name="chapterVideo" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否允许试看：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('feather_chapter_video')}">
                        <input type="radio" th:id="${'videoPreview_' + dict.dictCode}" name="videoPreview" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'videoPreview_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "cloudcourse/chapter"
        $("#form-chapter-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-chapter-add').serialize());
            }
        }

        /*总章节-新增-选择父总章节树*/
        function selectChapterTree() {
            var options = {
                title: '总章节选择',
                width: "380",
                url: prefix + "/selectChapterTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
               $("#treeId").val(body.find('#treeId').val());
               $("#treeName").val(body.find('#treeName').val());
               layer.close(index);
        }
    </script>
</body>
</html>